import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store'

Vue.use(VueRouter)



const routes = [
  {
    path: '/',
    name: 'Demo',
    component: () => import('../views/Demo.vue'),
    children: [
      //首页
      {
        path: 'Home',
        name: 'Home',
        alias: '',
        component: () => import('../views/Home.vue'),
      },
      {
        path: 'Mv',
        name: 'Mv',
        component: () => import('../views/Mv.vue'),
      },
      {
        path: 'Mine',
        name: 'Mine',
        component: () => import('../views/Mine.vue'),
      },


    ]
  },
  {
    path: '/Detail',
    name: 'Detail',
    component: () => import('../views/Detail.vue'),
    meta:{
      hg:1
    }
  }

]





const router = new VueRouter({
  routes
})
 router.beforeEach((to,from,next)=>{
  console.log(to.meta.hg)
  if(to.meta.hg){
    store.commit('updataHg',to.meta.hg)
  }else{
    store.commit('updataHg',50)
  }

  console.log(from)

  next()
 })
export default router
